/*
 * timers_hw.h
 *
 *  Created on: Sep 14, 2013
 *      Author: Ken Arok
 */

#ifndef TIMERS_HW_H_
#define TIMERS_HW_H_

#include "compiler.h"


typedef void (*TimerFuncVoid_t)(void *_param);

/* Timer/Counter 500ms. */
extern volatile uint32_t TimersArray500ms[16];
/* Timer/Counter 10ms. */
extern volatile uint32_t TimersArray10ms[16];
/* Function array that can be passed to timer/counter 500ms. */
extern TimerFuncVoid_t FuncArray500ms[16];
/* Function array that can be passed to timer/counter 10ms. */
extern TimerFuncVoid_t FuncArray10ms[16];
/* Parameter array that can be passed to timer/counter 500ms. */
extern void *ParamFuncArray500ms[16];
/* Parameter array that can be passed to timer/counter 10ms. */
extern void *ParamFuncArray10ms[16];


/** \brief Register a function to be executed in Timer 500ms.
 *
 * \param _func		Function to be registered.
 * \param _param	Parameter to be passed.
 *
 */
extern void vTimer500msFuncReg(TimerFuncVoid_t _func, void *_param);

/** \brief Unregister a function from Timer 500ms.
 *
 * \param _func		Function to be unregistered.
 *
 */
extern void vTimer500msFuncUnreg(TimerFuncVoid_t _func);

/** \brief Register a function to be executed in Timer 10ms.
 *
 * \param _func		Function to be registered.
 * \param _param	Parameter to be passed.
 *
 */
extern void vTimer10msFuncReg(TimerFuncVoid_t _func, void *_param);

/** \brief Unregister a function from Timer 10ms.
 *
 * \param _func		Function to be unregistered.
 *
 */
extern void vTimer10msFuncUnreg(TimerFuncVoid_t _func);

/** \brief Take hardware 10ms timer/counter.
 *
 * \return	Pointer of timer variable.
 *
 */
extern volatile void *vTimer10msTake(void);

/** \brief Take hardware 500ms timer/counter.
 *
 * \return	Pointer of timer variable.
 *
 */
extern volatile void *vTimer500msTake(void);

/** \brief Give/release 10ms hardware timer/counter.
 *
 * \param _tmrAddr	Pointer to the address of obtained timer.
 *
 */
extern void vTimer10msGive(volatile void *_tmrAddr);

/** \brief Give/release 500ms hardware timer/counter.
 *
 * \param _tmrAddr	Pointer to the address of obtained timer.
 *
 */
extern void vTimer500msGive(volatile void *_tmrAddr);


#endif /* TIMERS_HW_H_ */
